﻿using SqlKata;
using SqlKataDemo.GraphQLApi.Services;

namespace SqlKataDemo.GraphQLApi.GraphTypes
{
    [ExtendObjectType(typeof(QueryType))]
    public class OrderResolver
    {
        public Order GetOrder([Service] IDbFactory dbFactory)
        {
            var query = new Query("order");
            var order = dbFactory.GetFactory().Get<Order>(query).FirstOrDefault();
            return order;
        }
    }

    public class Order
    {
        public int Id { get; set; }
        public string Name { get; set; }
        public int ProductId { get; set; }
    }
}
